﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace Grundy.Message
{
    
    [CollectionDataContract]
    public class LicenseEntitlementCollection : ICollection<LicenseEntitlement>
    {
        private List<LicenseEntitlement> _licenseEntitlements;

        public LicenseEntitlementCollection()
        {
            _licenseEntitlements = new List<LicenseEntitlement>();
        }

        public LicenseEntitlementCollection(IEnumerable<LicenseEntitlement> licenseEntitlements)
        {
            _licenseEntitlements = licenseEntitlements.ToList();
        }

        public IEnumerator<LicenseEntitlement> GetEnumerator()
        {
            return _licenseEntitlements.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public void Add(LicenseEntitlement item)
        {
            _licenseEntitlements.Add(item);
        }

        public void Clear()
        {
            _licenseEntitlements.Clear();
        }

        public bool Contains(LicenseEntitlement item)
        {
            return _licenseEntitlements.Contains(item);
        }

        public void CopyTo(LicenseEntitlement[] array, int arrayIndex)
        {
            _licenseEntitlements.CopyTo(array, arrayIndex);
        }

        public bool Remove(LicenseEntitlement item)
        {
            return _licenseEntitlements.Remove(item);
        }

        public int Count
        {
            get { return _licenseEntitlements.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }
    }
}